Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

*: hide secure information in SHOW PROCESSLIST #4451

Merged
merged 9 commits into from
Sep 12, 2017

Conversation

tiancaiamao
Copy link
Contributor

show processlist should not display something like password.

@zimulala @coocood @shenli

ast/ast.go Outdated
@@ -37,6 +37,8 @@ type Node interface {
Text() string
// SetText sets original text to the Node.
SetText(text string)
// SecureText is different from Text that it hide password information.
SecureText() string
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this method should not be put in Node interface.
How about defining a CrusialStmt interface which only has a SecureText method?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So we implement SecureText() for so many

*ast.CreateUserStmt, *ast.DropUserStmt, *ast.AlterUserStmt, *ast.SetPwdStmt, *ast.GrantStmt,
*ast.RevokeStmt, *ast.AlterTableStmt, *ast.CreateDatabaseStmt, *ast.CreateIndexStmt, *ast.CreateTableStmt,
*ast.DropDatabaseStmt, *ast.DropIndexStmt, *ast.DropTableStmt, *ast.RenameTableStmt, *ast.TruncateTableStmt:

and most of those implemention is just ... ?

func (x *XXX) SecureText() string {
    return x.Text()
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, not all crucial statement need to have secure text.
Then how about define a SensitiveStatement which has SecureText?

Copy link
Member

@coocood coocood Sep 6, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if ss, ok := node.(SensitiveStmt); ok {
    text = ss.SecureText()
} else {
    text = node.Text()
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we add SecureText to StmtNode interface?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shenli
SecureText only needed by 4 statements, I think adding it to all StmtNode is not worthy.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

@shenli
Copy link
Member

shenli commented Sep 8, 2017

@tiancaiamao Any update?

@tiancaiamao
Copy link
Contributor Author

PTAL @coocood @shenli

ast/misc.go Outdated
@@ -406,6 +408,11 @@ type SetPwdStmt struct {
Password string
}

// SecureString implements SensitiveStatement interface.
func (n *SetPwdStmt) SecureString() string {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SecureText or SecureString?

@coocood
Copy link
Member

coocood commented Sep 11, 2017

Please add test.

@coocood
Copy link
Member

coocood commented Sep 11, 2017

LGTM

@tiancaiamao tiancaiamao added the status/LGT1 Indicates that a PR has LGTM 1. label Sep 12, 2017
@tiancaiamao
Copy link
Contributor Author

/run-all-test

@tiancaiamao
Copy link
Contributor Author

PTAL @zimulala @shenli

@zimulala
Copy link
Contributor

LGTM

@zimulala zimulala added the status/LGT2 Indicates that a PR has LGTM 2. label Sep 12, 2017
@zimulala zimulala removed the status/LGT1 Indicates that a PR has LGTM 1. label Sep 12, 2017
@tiancaiamao tiancaiamao merged commit 3428d80 into master Sep 12, 2017
@tiancaiamao tiancaiamao deleted the tiancaiamao/processlist-password branch September 12, 2017 06:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status/LGT2 Indicates that a PR has LGTM 2.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants